package com.dragon.repository.domain.vo;

import com.dragon.common.model.Update;
import com.dragon.common.util.BeanUtils;
import com.dragon.repository.entity.Customer;
import com.dragon.repository.entity.WorkflowJson;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;


/**
 * @author sy
 */
@Data
@ApiModel(value = "")
public class CustomerVO {

    private static final long serialVersionUID = 1L;

    private Integer id;

    @ApiModelProperty(value = "客户名称")
    @NotNull(message = "客户名称不能为空")
    private String customerName;

    @ApiModelProperty(value = "用户id")
    private Integer adminId;

    @ApiModelProperty(value = "部门id")
    private Integer departmentId;

    @ApiModelProperty(value = "手机")
    @NotNull(message = "手机号不能为空")
    private String phone;

    @ApiModelProperty(value = "删除标识：0未删除，1删除")
    private Integer deleted;

    @ApiModelProperty(value = "状态：0 待审核 1审核通过 2审核不通过 3作废 4删除")
    private Integer status;

    @ApiModelProperty(value = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;

    @ApiModelProperty(value = "更改时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date updateTime;

    @ApiModelProperty(value = "员工人数")
    private Integer numberofemployees;

    @ApiModelProperty(value = "公司性质")
    private String natureofbusiness;

    @ApiModelProperty(value = "客户类型")
    private Integer customertype;

    @ApiModelProperty(value = "客户行业：1.IT 2.金融业 3.房地产 4.商务服务 5.运输/物流 6.生产 7.政府 8.文化传媒")
    private Integer profession;


    @ApiModelProperty(value = "电话")
    private String telephone;

    @ApiModelProperty(value = "联系人")
    private String firstcontacter;

    @ApiModelProperty(value = "传真")
    private String fax;

    @ApiModelProperty(value = "Email")
    private String email;

    @ApiModelProperty(value = "地址")
    private String address;

    @ApiModelProperty(value = "支付方式：1银行转账 2微信 3支付宝 4现金 5支票")
    private Integer paymethod;

    @ApiModelProperty(value = "备注")
    private String memo;

    @ApiModelProperty(value = "技术联系人id")
    private Integer technicalId;

    @ApiModelProperty(value = "银行账号")
    private String bankAccount;

    @ApiModelProperty(value = "开户行名称")
    private String bankName;

    @ApiModelProperty(value = "法定代表人")
    private String legalAdmin;

    @ApiModelProperty(value = "工作流json")
    private List<WorkflowJson> workflowJsonList;

    @ApiModelProperty(value = "免审操作：0，不免审，1免审")
    private Integer exempt;

    @ApiModelProperty(value = "结算方式：1现结，2月结")
    private Integer settlement;


    @NotNull(groups = Update.class,message = "主键不能为空")
    public static Customer convert(CustomerVO vo) {
        Customer entity = new Customer();
        BeanUtils.copyProperties(vo,entity);
        return entity;
    }
    public static List<Customer> convertList(List<CustomerVO> list) {
        List<Customer> resultList = new ArrayList<>();
        for (CustomerVO vo : list) {
            resultList.add(convert(vo));
        }
        return resultList;
    }
}
